package Code;

public class Tank {

	//fields derived from https://facwiki.cs.byu.edu/cs470sp11/index.php/BZRC_Protocol#mytanks
	private int id;
	private String callsign;
	private String status;
	private int shotsAvailable;
	private double timeToReload;
	private Team flag;
	private double x;
	private double y;
	private double angle;
	private double vx;
	private double vy;
	private double angvel; //angular velocity in radians per second
	
	public Tank() {
		
	}
	
	public Tank(String[] attrs) {
		this.setId(Integer.parseInt(attrs[1]));
		this.setCallsign(attrs[2]);
		this.setStatus(attrs[3]);
		this.setShotsAvailable(Integer.parseInt(attrs[4]));
		this.setTimeToReload(Double.parseDouble(attrs[5]));
		this.setFlag(attrs[6]);
		this.setX(Double.parseDouble(attrs[7]));
		this.setY(Double.parseDouble(attrs[8]));
		this.setAngle(Double.parseDouble(attrs[9]));
		this.setVx(Double.parseDouble(attrs[10]));
		this.setVy(Double.parseDouble(attrs[11]));
		this.setAngvel(Double.parseDouble(attrs[12]));
	}
	
	public Point getLocation() {
		return new Point(this.getX(), this.getY());
	}
	
	public void setLocation(final Point point) {
		this.setX(point.getX());
		this.setY(point.getY());
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getCallsign() {
		return callsign;
	}
	public void setCallsign(String callsign) {
		this.callsign = callsign;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public int getShotsAvailable() {
		return shotsAvailable;
	}
	public void setShotsAvailable(int shotsAvailable) {
		this.shotsAvailable = shotsAvailable;
	}
	public double getTimeToReload() {
		return timeToReload;
	}
	public void setTimeToReload(double d) {
		this.timeToReload = d;
	}
	public Team getFlag() {
		return flag;
	}
	public void setFlag(Team flag) {
		this.flag = flag;
	}
	public void setFlag(String flag) {
		if(flag.equalsIgnoreCase("-")) {
			this.flag = Team.NONE;
		} else {
			this.flag = Team.valueOf(flag.toUpperCase());
		}
	}
	public boolean hasFlag() {
		return flag != Team.NONE;
	}
	public double getX() {
		return x;
	}
	public void setX(double d) {
		this.x = d;
	}
	public double getY() {
		return y;
	}
	public void setY(double d) {
		this.y = d;
	}
	public double getAngle() {
		return angle;
	}
	public void setAngle(double angel) {
		this.angle = angel;
	}
	public double getVx() {
		return vx;
	}
	public void setVx(double d) {
		this.vx = d;
	}
	public double getVy() {
		return vy;
	}
	public void setVy(double d) {
		this.vy = d;
	}
	public double getAngvel() {
		return angvel;
	}
	public void setAngvel(double d) {
		this.angvel = d;
	}
	
}
